package io.renren.modules.admin.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import io.renren.common.utils.PageUtils;
import io.renren.common.utils.Query;
import io.renren.modules.admin.dao.BannerDao;
import io.renren.modules.admin.entity.BannerEntity;
import io.renren.modules.admin.service.BannerService;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;



@Service("bannerService")
public class BannerServiceImpl extends ServiceImpl<BannerDao, BannerEntity> implements BannerService {

    @Override
    public PageUtils queryPage(Map<String, Object> params) {
        IPage<BannerEntity> page = this.page(
                new Query<BannerEntity>().getPage(params),
                new QueryWrapper<BannerEntity>()
        );

        return new PageUtils(page);
    }

    @Override
    public List<BannerEntity> getListByWrapper(Map<String, Object> params) {
        Boolean isShow = (Boolean)params.get("isShow");
        QueryWrapper<BannerEntity> wrapper = new QueryWrapper<>();
        wrapper.eq(isShow!=null,"is_show",isShow);
        List<BannerEntity> bannerEntities = baseMapper.selectList(wrapper);
        return bannerEntities;
    }


}